package com.lsp.rocketmqcousumer.receiver;

import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 顺序消费
 * 消费者需要指定顺序消费（默认异步）
 */
@Component
@RocketMQMessageListener(
        topic = "orderlyTopic",
        consumerGroup = "CONSUME_GROUP_TEST",
        /**指定顺序消费**/
        consumeMode = ConsumeMode.ORDERLY
)
public class OrderlyReceiver implements RocketMQListener<String> {

    @Override
    public void onMessage(String msg) {
        System.out.printf("Consumer 顺序消费，收到消息: %s \n",msg);
    }
}
